package top.saplf.sileny.ext

/**
 * @author Saplf on 17/4/15
 */
/**
 * 分割文件名，first为文件名称，second为后缀名
 */
fun String.splitFileName(): Pair<String, String> {
    val dotIndex = lastIndexOf('.')
    return if (dotIndex == -1) {
        Pair(this, "")
    } else {
        Pair(substring(0, dotIndex), substring(dotIndex + 1, length))
    }
}

fun Any?.musicMetaData(): String = with(toString()) {
    val start = indexOfFirst { it == '"' }
    val end = indexOfLast { it == '"' }
    if (start == -1 || end == -1) {
        return ""
    }
    return substring(start + 1 until end)
}

fun String.musicAuthors(): List<String> = split('/')
